/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.fullhappy.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author hiep
 */
@Entity
@Table(name = "music")
public class Music implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    
    @Column(name = "music_id")
    private Integer musicId;
    
    @Column(name = "title")
    private String title;
    @Lob
    @Column(name = "description")
    private String description;
    @Column(name = "author_ids")
    private String authorIds;
    @Column(name = "singer_ids")
    private String singerIds;
    @Column(name = "category_id")
    private int categoryId;
    @Column(name = "create_time")
    private long createTime;
    
    @Column(name = "user_create_id")
    private int userCreateId;
    
    @Column(name = "enable")
    private short enable;
    
    @Column(name = "type_id")
    private int typeId;
    @Column(name = "avatar_image_link")
    private String avatarImageLink;
    
    @Column(name = "source_file")
    private String sourceFile;
    
    @Column(name = "file_type_id")
    private short fileTypeId;

    public Music() {
    }

    public Music(Integer musicId) {
        this.musicId = musicId;
    }

    public Music(Integer musicId, String title, long createTime, int userCreateId, short enable, int typeId, String sourceFile, short fileTypeId) {
        this.musicId = musicId;
        this.title = title;
        this.createTime = createTime;
        this.userCreateId = userCreateId;
        this.enable = enable;
        this.typeId = typeId;
        this.sourceFile = sourceFile;
        this.fileTypeId = fileTypeId;
    }

    public Integer getMusicId() {
        return musicId;
    }

    public void setMusicId(Integer musicId) {
        this.musicId = musicId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getAuthorIds() {
        return authorIds;
    }

    public void setAuthorIds(String authorIds) {
        this.authorIds = authorIds;
    }

    public String getSingerIds() {
        return singerIds;
    }

    public void setSingerIds(String singerIds) {
        this.singerIds = singerIds;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public int getUserCreateId() {
        return userCreateId;
    }

    public void setUserCreateId(int userCreateId) {
        this.userCreateId = userCreateId;
    }

    public short getEnable() {
        return enable;
    }

    public void setEnable(short enable) {
        this.enable = enable;
    }

    public int getTypeId() {
        return typeId;
    }

    public void setTypeId(int typeId) {
        this.typeId = typeId;
    }

    public String getAvatarImageLink() {
        return avatarImageLink;
    }

    public void setAvatarImageLink(String avatarImageLink) {
        this.avatarImageLink = avatarImageLink;
    }

    public String getSourceFile() {
        return sourceFile;
    }

    public void setSourceFile(String sourceFile) {
        this.sourceFile = sourceFile;
    }

    public short getFileTypeId() {
        return fileTypeId;
    }

    public void setFileTypeId(short fileTypeId) {
        this.fileTypeId = fileTypeId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (musicId != null ? musicId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Music)) {
            return false;
        }
        Music other = (Music) object;
        if ((this.musicId == null && other.musicId != null) || (this.musicId != null && !this.musicId.equals(other.musicId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return title;
    }

    public void setSingerIds(int[] singerIds) {
        String ids = "";
        for(int i : singerIds){
            ids+=i+" ";
        }
        setSingerIds(ids.trim());
    }
    
}
